package baseStructure;

/**
 * @author Sebastian Mæland Pedersen
 */

import java.util.HashMap;

public class Log {
	// enable/disable all logging
	private static boolean LOG = true;
	
	// add/remove/enable/disable log messages
	// there are probably better ways to do this but it will do for now
	private static HashMap<String, Boolean> enabled;
	static
    {
        enabled = new HashMap<String, Boolean>();
        enabled.put("DEBUG", true);
        enabled.put("INFO", true);
        enabled.put("WARNING", true);
        enabled.put("ERROR", true);
    }
	
	private Log() { }
	
	/**
	 * @param key - Identifier
	 * @param msg - Object to be printed
	 */
	public static void print(String key, Object msg) {
		if (LOG && enabled.containsKey(key) && enabled.get(key)) {
			System.out.println(key + ": " + msg);
		}
	}
	
	/**
	 * @param msg - Object to be printed
	 */
	public static void d(Object msg) {
		print("DEBUG", msg);
	}
	
	/**
	 * @param msg - Object to be printed
	 */
	public static void w(Object msg) {
		print("WARNING", msg);
	}
	
	/**
	 * @param msg - Object to be printed
	 */
	public static void i(Object msg) {
		print("INFO", msg);
	}

	/**
	 * @param msg - Object to be printed
	 */
	public static void e(Object msg) {
		print("ERROR", msg);
	}
}
